package com.yy.chapter9.controller;

import com.yy.chapter9.bean.TestBean;
import com.yy.chapter9.configuration.ApplicationContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangyao
 * @Description: TestController
 * @date 2018/10/29 14:22
 */
@RestController
public class TestController {

//    /**
////     * 传统注入获取方式
////     */
////    @Autowired
////    private TestBean testBean;


    @GetMapping(value = "/test")
    public String testString(){
        TestBean testBean = (TestBean) ApplicationContextHolder.getBean("testBean");
        TestBean testBean1 =  ApplicationContextHolder.getBean(TestBean.class);
        TestBean testBean2 =  ApplicationContextHolder.getBean("testBean",TestBean.class);
        testBean.test();
        testBean1.test();
        testBean2.test();
        return testBean.toString()+"===="+testBean1.toString()+"===="+testBean2.toString();
    }
}
